#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
using ll = long long;
const int N = 50010, M = 999997;
int n, m;
struct pi
{
    int x, y, r;
}p[N];
bool st[M];
int id[M];
ll h[M];
ll sqr(int x)
{
    return x * x;
}
ll get_key(int x, int y)
{
    return x * 1000000001ll + y;
}
int find(int x, int y)
{
    ll key = get_key(x, y);
    int t = (key % M + M) % M;
    while (h[t] != -1 && h[t] != key)
    {
        if (++t == M) t = 0;
    }
    return t;
}
void dfs(int x, int y, int r)
{
    st[find(x, y)] = true;
    for (int i = x - r; i <= x + r; i++)
    {
        for (int j = y - r; j <= y + r; j++)
        {
            if (sqr(i - x) + sqr(j - y) <= sqr(r))
            {
                int t = find(i, j);
                if (id[t] && !st[t]) dfs(i, j, p[id[t]].r);
            }
        }
    }
}
int main()
{
    memset(h, -1, sizeof h);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i].x >> p[i].y >> p[i].r;
        int t = find(p[i].x, p[i].y);
        if (h[t] == -1) h[t] = get_key(p[i].x, p[i].y);
        if (!id[t] || p[id[t]].r < p[i].r)
        {
            id[t] = i;
        }
    }
    while (m--)
    {
        int x, y, r;
        cin >> x >> y >> r;
        for (int i = x - r; i <= x + r; i++)
        {
            for (int j = y - r; j <= y + r; j++)
            {
                if (sqr(i - x) + sqr(j - y) <= sqr(r))
                {
                    int t = find(i, j);
                    if (id[t] && !st[t]) dfs(i, j, p[id[t]].r);
                }
            }
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (st[find(p[i].x, p[i].y)]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}